var regBox = { 

        regEmail : /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/,//邮箱 

        regName : /^[a-z0-9_-]{3,16}$/,//用户名 

        regMobile : /^0?1[3|4|5|7|8][0-9]\d{8}$/,//手机 

        regTel : /^0[\d]{2,3}-[\d]{7,8}$/ ,
        
        uploadExcelFile : /^.*?\.(jpg|jpeg|png|gif|bmp)$/

    };  
$(document).ready(function() {
	document.domain = cookieDomain;
	$('body').on({
		change:function(){
			if (!($(this).val() != "" 
			 && regBox.uploadExcelFile.test($(this).val().toLowerCase()))) {
				$.messager.alert('提示', '请选择正确的封面图', 'error');
				$(this).val('');
				return ;
			} else {
				$('#addArticleForm').attr('action',mainDomain + '/picroom/uploadCoverPic.action');
				$('#addArticleForm').attr('target','file_upload_return');
				$('#addArticleForm').submit();
			}
		}
	},'#uploadCoverPicBtn');
	
	$("#file_upload_return").load(function(loadData){
    	$('#file_upload_return').hide();
    	var returnObj = $('body', window.frames['file_upload_return'].document).find('#uploadResultId');
    	var data = returnObj.val();
        if(data != undefined && data != ''){
        	if (parseInt(data) == 1) {
        		var url = returnObj.attr('data-url');
        		if (url != undefined && url != '') {
        			var allUrl = staticDomain + url;
        			var smallUrl = allUrl + '_100x100.jpg';
        			$('#uploadCoverPicBtn').prevAll().remove();
        			$('#uploadCoverPicBtn').before('<img src="'+ smallUrl +'"><input type="hidden" name="coverPicUrl" value="'+ url +'">');
        		}
        	} else {
        		/*
           		if (parseInt(data) == -3) {
           			$("#ai").removeClass("disabled");
           			addTip($("#idPhoto"),"请上传身份证合照",'error');
           		} else if (parseInt(data) == -4) {
           			$("#ai").removeClass("disabled");
           			addTip($("#idPhoto"),"证件照片格式仅支持jpg、png、gif",'error');
           		} else if (parseInt(data) == -5) {
           			$("#ai").removeClass("disabled");
           			addTip($("#idPhoto"),"证件照片不能超过5M",'error');
           		} else {
                       $("#ai").removeClass("disabled");
                       addTip($("#ai"),"暂时无法提交",'error');
           		}
           		$("#ai").html("确认提交");
           		*/
           	}
        }
    });
});
